<?
    global $mySession;

    if ($this->gridType == '3')
    {
        ?>
        <script type="text/javascript" src="<?= JS_URL ?>gsearch.js"></script>
        <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript" src="<?= JS_URL ?>imgPreview.js"></script>    
        <script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox.js"></script>
        <!--<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>	-->
        <?
    }
?>
<style type="text/css">
    .banner_header{
        padding: 0;
    }
    .banner_header #search_params{
        margin-bottom: 0;
    }
    #on_site_facility,#Holiday_themes,#swimming_pool, #Bedroom, #Bathroom, #ppty_facility{display:list-item;list-style-type:none;}
    .star_rank
    {
        width:auto !important;	
    }
    .edit_btns div
    {
        float:right !important;	
    }
    .ppty_list_search table
    {
        width:60% !important;	
    }
</style>
<script type="text/javascript" src="<?= JS_URL_ADMIN ?>jquery.ui.accordion.js"></script>
<script type="text/javascript">
    show = 0;
    $(document).ready(function(e) {
        $('#chosenSearch').chosen();
        $("#Datefrom").datepicker({minDate: new Date(), dateFormat: "dd-mm-yy"});
        var selectedDate = new Date();
        if ($('#Datefrom').val() != "")
            var selectedDate = new Date($('#Datefrom').val());
        var msecsInADay = 604800000;
        $("#Dateto").datepicker({minDate: new Date(selectedDate.getTime() + msecsInADay)});
        $("#laterDate").click(function() {
            if ($("#laterDate").attr('checked'))
            {
                $("input[type='text']").filter(":not('#textfield')").val("");
                $("input[type='text']").filter(":not('#textfield')").attr("disabled", "disabled");

            }
            else
                $("input[type='text']").removeAttr("disabled", "disabled");

        });



        if ($("#laterDate").attr("checked"))
        {
            $("#laterDate").prevAll("input").val("");
            $("input[type='text']").filter(":not('#keySearch')").attr("disabled", "disabled");
        }


        //code for removing ticks from all sizes
        $("p.bedroom :checkbox").not(":first").change(function(e) {


            if ($(this).is(":checked"))
            {
                $("#all_bedroom").removeAttr("checked");

            }
        });


        //code for removing ticks from other sizes
        $("#all_bedroom").change(function(e) {
            $("p.bedroom :checkbox").not(":first").removeAttr("checked");
        });

        //code for removing ticks from other sizes
        $("#all_bathroom").change(function(e) {
            $("p.bathroom :checkbox").not(":first").removeAttr("checked");
        });


        //code for removing ticks from all sizes of bathrooms
        $("p.bathroom :checkbox").not(":first").change(function(e) {


            if ($(this).is(":checked"))
            {
                $("#all_bathroom").removeAttr("checked");

            }
        });





        $('#chosenSearch_chzn').css({float: "left", margin: "0 20px 0 0"});  // adding style to the select box in search filter(delete)


        //event handler for sorting

        $("#sorti").change(function(e) {

            $("#search_form").submit();

        })


        $("#close_delete").click(function(e) {
            $("#accordion-container").find("input:checkbox:checked").not($("#Bedroom").find("input:checkbox").first()).not($("#Bathroom").find("input:checkbox").first()).removeAttr("checked");
            //console.log($("#accordion-container").find("input:checkbox:checked").not($("#Bedroom").find("input:checkbox").first()).not($("#Bathroom").find("input:checkbox").first()).removeAttr("checked"));
            //$("#hotelsearch").submit();

        });


    });


    function reset_filter()
    {


        $("#accordion-container").find("input:checkbox:checked").not($("#Bedroom").find("input:checkbox").first()).not($("#Bathroom").find("input:checkbox").first()).removeAttr("checked");


        $("#hotelsearch").submit();
        //$(".accordion-content").filter(":eq("+parseInt(ch[1])+")").find(":checkbox:checked").eq(parseInt(ch[2])-1).removeAttr("checked");	


    }

    /*function showFav(id)
     {
     //	console.log(id.attr("id"));
     if(show)
     show = 0;
     else
     show = 1;
     
     $("#"+id).toggleClass("SwitchFavoritePanel_open",show);
     $("#"+id).toggleClass("SwitchFavoritePanel_close",show);
     
     
     if(show)
     $(".FavBox").fadeIn("slow",function(){
     });
     else
     $(".FavBox").fadeOut("slow",function(){
     });
     
     
     
     }*/

    /*function openBox(id)
     {
     $("#"+id).toggleClass("SwitchFavoritePanel_open",1);
     $("#"+id).toggleClass("SwitchFavoritePanel_close",0);
     
     
     $(".FavBox").fadeIn("slow",function(){
     });
     
     }
     */
    /*function loadFav()
     {
     
     for(var i = 0;i<12;i++)
     {
     $("#box_"+i).load('<?= APPLICATION_URL ?>search/loadfav/sno/'+i,function(data){
     
     });	
     }
     
     }
     
     function add_as_favourite(id,ptr)
     {
     
     if($("#"+ptr).find("span").text() == "Add as Favourite")
     {	
     $("#"+ptr).find("span").text("Remove as Favourite") ;
     var del = '0';
     }
     else
     {	
     $("#"+ptr).find("span").text("Add as Favourite") ;
     var del = '1';
     }
     
     
     
     $.ajax({
     
     url: "<?= APPLICATION_URL ?>search/savefav/ppty/"+id+"/del/"+del,
     async:false,
     success:function(data){
     
     data = $.trim(data);
     if(data == 'fail')
     {	alert("Maximum Limit Reached");
     $("#"+ptr).find("span").text("Add as Favourite") ;
     }
     }
     
     });		
     
     
     openBox(id);	
     
     loadFav();
     
     
     $(".FavBox").focus();
     }*/

    function checkoutdate(value)
    {

        var selectedDate = new Date(value);
        if (selectedDate == "")
        {
            selectedDate = new Date();
        }
        var m = selectedDate.getMonth();
        var y = selectedDate.getYear();
        var d = selectedDate.getDate();

        var msecsInADay = 604800000;
        var endDate = new Date(selectedDate.getTime() + msecsInADay);
        $("#Dateto").datepicker("option", "minDate", endDate);


    }

    function gridtype(id)
    {
        $("#grid").val(id);
        $("#search_form").submit();

    }
</script>
<?
    $db = new Db();

    $availableTags = '[';
    $i = 1;
    if (@count($resData) > 0)
        foreach ($resData as $key => $row)
        {
            $availableTags.='"' . $row['property_title'] . '"';
            if (count($resData) != $i)
            {
                $availableTags.=',';
            }
            $i++;
        }
    $availableTags.=']';
?>
<script src="<?= APPLICATION_URL ?>vallenato/vallenato.js" type="text/javascript"></script>
<link rel="stylesheet" href="<?= APPLICATION_URL ?>vallenato/vallenato.css" type="text/css" media="screen">
<?
    $db = new Db();
?>
<div class="mws-panel-body">
    <!-- Search Panel With Baner Start-->
    <?php
        if ($this->gridType == '3')
        {
            $gMap = "";
            if (!empty($this->propertyData))
            {
                foreach ($this->propertyData as $values)
                {
                    if ($values['cletitude'])
                    {
                        $gMap .= $values['cletitude'] . "," . $values['clongitude'] . "," . $values['pid'] . "|||";
                    }
                }
                $gMap = substr($gMap, 0, strlen($gMap) - 3);
            }
            ?>	
            <input type="hidden" name="gField" id = "gField" value="<?= $gMap ?>" />
            <div id="map_canvas" style="height:500px;width:100%;float:right;">
            </div>
            <?php
        }
    ?>
    <div class="search_panel">
        <div class="sp_heding">Advance Search</div>
        <br/> <br/>
        <form action="<?php echo $this->url(array('controller' => 'search', 'action' => 'property'), 'default', true) ?>" method="get" id = "hotelsearch" name = "hotelsearch"> 
            <div id="accordion-container">

                <h2 class="accordion-header">Search</h2>
                <div class="accordion-content" style="display:inline-block">
                    <p>        
                    <div class="form_area_row search_box_padding">
                        <div class="form_area_row_inner1">
                            <div class="form_area_row_text">Country</div>
                            <div class="form_area_row_box">
                                <?= $this->myform->country_id ?>
                            </div>
                        </div>
                    </div>
                    <div class="form_area_row" id="state_id_div" style="display:none;">
                        <div class="form_area_row_inner1">
                            <div class="form_area_row_text">State/Region</div>
                            <div class="form_area_row_box">
                                <?= $this->myform->state_id ?>
                            </div>
                        </div>
                    </div>
                    <div class="form_area_row" id="city_id_div" style="display:none;">
                        <div class="form_area_row_inner1">
                            <div class="form_area_row_text">City Location</div>
                            <div class="form_area_row_box">
                                <?= $this->myform->city_id ?>
                            </div>
                        </div>
                    </div>   
                    <div class="form_area_row" id="sub_area_id_div" style="display:none;">
                        <div class="form_area_row_inner1">
                            <div class="form_area_row_text">Sub Area</div>
                            <div class="form_area_row_box">
                                <?= $this->myform->sub_area_id ?>
                            </div>
                        </div>
                    </div>   

                    <div class="form_area_row" id="local_area_id_div" style="display:none;">
                        <div class="form_area_row_inner1">
                            <div class="form_area_row_text">Local Area</div>
                            <div class="form_area_row_box">
                                <?= $this->myform->local_area_id ?>
                            </div>
                        </div>
                    </div>   
                    <div class="form_area_row" id="check_in_div" >
                        <div class="form_area_row_inner1">
                            <div class="form_area_row_text">Check-in-date</div>
                            <div class="form_area_row_box">
                                <input type="text" name = "Datefrom" id = "Datefrom" value="<?= $this->Datefrom ?>" onchange = "checkoutdate(this.value);"/>
                            </div>
                        </div>
                    </div>   

                    <div class="form_area_row"  >
                        <div class="form_area_row_inner1">
                            <div class="form_area_row_text">Nights</div>
                            <div class="form_area_row_box">
                                <select name="DateTo" id="DateTo">
                                    <?
                                        for ($i = 7; $i <= 60; $i++)
                                        {
                                            if ($this->Dateto == $i)
                                                $selected = "selected='selected'";
                                            else
                                                $selected = "";
                                            ?>
                                            <option <?= $selected ?> value="<?= $i ?>"><?= $i ?></option>
                                            <?
                                        }
                                    ?>
                                </select>
                            </div>
                        </div>
                    </div> 
                    <div class="form_area_row" id="local_area_id_div" >
                        <div class="form_area_row_inner1">
                            <div class="form_area_row_text">I will decide dates later</div>
                            <div class="form_area_row_box">
                                <?
                                    if ($this->laterDate == 'on')
                                        $checked = "checked='checked'";
                                    else
                                        $checked = "";
                                ?>
                                <input type="checkbox" name="laterDate" id="laterDate" <?= $checked ?> />
                            </div>
                        </div>
                    </div>    
                    <div class="check_bttn_advance "><input class="btns" type="image" src="<?= IMAGES_URL; ?>adv_search_btn.png" /></div>
                    </p>
                </div>
                <h2 class="accordion-header">Bedrooms</h2>
                <div class="accordion-content" id = "Bedroom" style="display:list-item;">
                    <p>
                        <?
                            for ($i = 0; $i < 5; $i++)
                            {
                                if (!in_array($this->bedroom[$i], array(1, 2, 3, 4, 5)))
                                {
                                    $checked = "checked='checked'";
                                }
                                else
                                {
                                    $checked = "";
                                    break;
                                }
                            }
                        ?>
                    <p class = "bedroom"> <input type="checkbox"  id = "all_bedroom" <?= $checked ?>   name="bedroom[]" value=""/>&nbsp;All Sizes&nbsp;<p/>
                    <br />
                    <?
                        for ($i = 1; $i < 6; $i++)
                        {
                            if (in_array($i, $this->bedroom))
                            {
                                $checked = 'checked="checked"';
                            }
                            else
                            {
                                $checked = '';
                            }
                            if ($i == 5)
                            {
                                ?>
                                <p class = "bedroom"> <input type="checkbox" <?= $checked ?> data-vallenato="<?php echo $i ?> + bedroom"   name="bedroom[]" value="<?= $i ?>"/>&nbsp;<?= $i ?> + Bed&nbsp;<p />
                                <?
                            }
                            else
                            {
                                ?>
                                <p class = "bedroom"><input type="checkbox" <?= $checked ?>  data-vallenato="<?php echo $i ?> bedroom" name="bedroom[]" value="<?= $i ?>"/>&nbsp;<span><?= $i ?> Bed&nbsp;</p><br />


                                <?
                            }
                        }
                    ?>
                    </p>
                </div>

                <div class="check_bttn_advance "><input class="btns" type="image" src="<?= IMAGES_URL; ?>adv_search_btn.png" /></div>

                <h2 class="accordion-header">Bathrooms</h2>
                <div class="accordion-content" id = "Bathroom" >
                    <p class = 'bathroom'> 
                        <?
                            for ($i = 0; $i < 4; $i++)
                            {

                                if (!in_array($this->bathroom[$i], array(2, 3, 4)))
                                    $checked = "checked='checked'";
                                else
                                {
                                    $checked = "";
                                    break;
                                }
                            }
                        ?>
                        <input type="checkbox" <?= $checked ?>  id = "all_bathroom" name="bathroom[]" value=""/>&nbsp;All Sizes&nbsp;<br /><br />

                        <?
                            for ($i = 2; $i < 5; $i++)
                            {
                                if (in_array($i, $this->bathroom))
                                {
                                    $checked = 'checked="checked"';
                                }
                                else
                                {
                                    $checked = '';
                                }

                                if ($i == 4)
                                {
                                    ?>
                                    <input type="checkbox" <?= $checked ?> name="bathroom[]" data-vallenato="<?php echo $i; ?> + bathrooms" value="<?= $i ?>"/>&nbsp;<?= $i ?> + Bathrooms <br /><br />

                                    <?
                                }
                                else
                                {
                                    ?>
                                    <input type="checkbox" <?= $checked ?> name="bathroom[]" data-vallenato="<?php echo $i; ?> bathrooms" value="<?= $i ?>"/>&nbsp;<?= $i ?> Bathrooms <br/><br />
                                    <?
                                }
                                ?>

                                <?
                            }
                        ?>
                    </p>


                </div>

                <div class="check_bttn_advance "><input class="btns" type="image" src="<?= IMAGES_URL; ?>adv_search_btn.png" /></div>

                <!-- Special Offer search box -->
                <h2 class="accordion-header">Special Offer</h2>
                <div class="accordion-content" id = "Special" >
                    <p class = 'special'> 
                        <?
                            foreach ($this->spclOfferArr as $spclVal)
                            {
                                ?>

                                <input type="checkbox" <?= in_array($spclVal['id'], $this->spclOffr) ? "checked='checked'" : ""; ?>  data-vallenato="<?php echo $spclVal['type_name'] ?>"  name="spcloffr[]" value="<?php echo $spclVal['id'] ?>"/>&nbsp;<?php echo $spclVal['type_name'] ?>&nbsp;<br /><br />
                                <?php
                            }
                        ?>

                    </p>


                </div>

                <div class="check_bttn_advance "><input class="btns" type="image" src="<?= IMAGES_URL; ?>adv_search_btn.png" /></div>

                <h2 class="accordion-header">Property Facilities</h2>
                <div class="accordion-content" id = "ppty_facility">
                    <p>
                        <?
                            $facilities = explode(",", FACILITIES);
                            $i = 0;

                            foreach ($this->specArr as $key => $row)
                            {


                                if (in_array($row['cid'], $facilities))
                                {
                                    if (in_array($row['cid'], $this->amenity))
                                    {
                                        $checked = 'checked="checked"';
                                    }
                                    else
                                    {
                                        $checked = '';
                                    }
                                    ?>

                                    <input type="checkbox" <?= $checked ?> name="amenityRow[]" data-vallenato="<?php echo $row['option']; ?>" value="<?= $row['cid'] ?>"/>&nbsp;<?= $row['option'] ?><br/><br />


                                    <?
                                }
                            }
                        ?>
                    </p>
                </div>

                <div class="check_bttn_advance "><input class="btns" type="image" src="<?= IMAGES_URL; ?>adv_search_btn.png" /></div>

                <!--<h2 class="accordion-header">Swimming Pool</h2>-->
                <h2 class="accordion-header">Sub-Areas</h2>
                <div class="accordion-content" id = "swimming_pool">
                    <p>
                        <?
                            $pools = explode(",", SWIMMING_POOLS);
                            $i = 0;

                            foreach ($this->specArr as $key => $row)
                            {


                                if (in_array($row['cid'], $pools))
                                {
                                    if (in_array($row['cid'], $this->swimming))
                                    {
                                        $checked = 'checked="checked"';
                                    }
                                    else
                                    {
                                        $checked = '';
                                    }
                                    ?>

                                    <input type="checkbox" <?= $checked ?> name="swimming[]" data-vallenato="<?php echo $row['option']; ?>" value="<?= $row['cid'] ?>"/>&nbsp;<?= $row['option'] ?><br/><br />


                                    <?
                                }
                            }
                        ?>


                    </p>
                </div>

                <div class="check_bttn_advance "><input class="btns" type="image" src="<?= IMAGES_URL; ?>adv_search_btn.png" /></div>

                <h2 class="accordion-header">On-Site Facilities</h2>
                <div class="accordion-content" id = "on_site_facility">
                    <p >
                        <?
                            $extras = explode(",", ON_SITE);
                            $i = 0;



                            foreach ($this->amenityArr as $key => $row)
                            {


                                if (in_array($row['amenity_id'], $extras))
                                {
                                    if (in_array($row['amenity_id'], $this->facilities))
                                    {
                                        $checked = 'checked="checked"';
                                    }
                                    else
                                    {
                                        $checked = '';
                                    }
                                    ?>

                                    <input type="checkbox" <?= $checked ?> name="facilities[]" data-vallenato="<?php echo $row['title']; ?>" value="<?= $row['amenity_id'] ?>"/>&nbsp;<?= $row['title'] ?><br /><br />



                                    <?
                                }
                            }
                        ?>
                    </p>
                </div>

                <div class="check_bttn_advance "><input class="btns" type="image" src="<?= IMAGES_URL; ?>adv_search_btn.png" /></div>

                <h2 class="accordion-header">Keyword or property ref</h2>
                <div class="accordion-content" style="display:inline-block;">

                    <div class="form_area_row_inner1">
                        <div class="form_area_row_text">Enter Keyword</div>
                        <div class="form_area_row_box">
                            <input type="text" data-vallenato="Keyword or Property ref" name="propertyname" value="<?= $this->propertyname ?>"  id="textfield"/>
                        </div>
                    </div>
                </div>

                <div class="check_bttn_advance "><input class="btns" type="image" src="<?= IMAGES_URL; ?>adv_search_btn.png" /></div>
                <h2 class="accordion-header">Holiday Themes</h2>
                <div class="accordion-content" id = "Holiday_themes">
                    <p>
                        <?
                            $themes = explode(",", THEMES);
                            foreach ($this->specArr as $key => $row)
                            {


                                if (in_array($row['cid'], $themes))
                                {
                                    if (in_array($row['cid'], $this->themes))
                                    {
                                        $checked = 'checked="checked"';
                                    }
                                    else
                                    {
                                        $checked = '';
                                    }
                                    ?>

                                    <input type="checkbox" <?= $checked ?> name="themes[]" data-vallenato="<?php echo $row['option']; ?>" value="<?= $row['cid'] ?>" border="0"/>&nbsp;<?= $row['option'] ?><br/><br />


                                    <?
                                }
                            }
                        ?>



                    </p>
                </div>
                <div class="check_bttn_advance "><input class="btns" type="image" src="<?= IMAGES_URL; ?>adv_search_btn.png" /></div>

            </div>    



        </form> 
    </div>




    <div class="content">

        <div class = "FavBox" nav-index='1' tabindex = '1'>
            <?
                for ($i = 0; $i < 10; $i++):

                    $class = "class='deactive'";

                    /* 	if($this->favArr[$i])
                      $class = "class='active'";
                      else
                      $class = "class='deactive'";
                     */
                    ?>
                    <div id = 'box_<?= $i ?>' <?= $class ?>>

                    </div>
                    <?
                endfor;
            ?>


        </div>
        <div id="search-tab-box" class="search-tabs" >
            <h4 style="color:#0187D5">My Selections:</h4>
            <br />
            <select id = "chosenSearch" multiple="multiple"  name = 'chosenSearch[]' style="width:100%;" >
            </select>
        </div>
        <div class="ppty_list_search_wrap"><!-- search property tab-->
            <?
                if ($this->gridType == '1'):
                    $i = 0;

                    foreach ($this->propertyData as $keys => $values)
                    {
                        if ($values['image_name'])
                            $image = $values['image_name'];
                        else
                            $image = "generic.jpg";
                        ?>	
                        <div class="ppty_list_search"><!-- box div (main) starts-->
                            <div class = 'left_panel_heading_ppty_search'> <!-- top div -->
                                <div class="location_bread_crum">
                                    <?= breadcrumb_trail($values['country_name'], $values['state_name'], $values['city_name'], $values['sub_area_name'], $values['local_area_name']) ?>
                                    <? /* if($values['address']) echo $values['address']; else echo "[No Location described]"; */ ?>
                                </div>
                            </div> <!-- top div ends -->           

                            <div class = 'img_wrapper_search'><!-- image content-->
                                <a title="<?php echo $values['image_title']; ?> - View Details" class="mws-tooltip-w" href="<?= APPLICATION_URL ?>holiday-rentals/<?= $values['country_name'] ?>/<?= $values['state_name'] ?>/<?= $values['city_name'] . "/" . ($values['sub_area_name'] ? $values['sub_area_name'] . '/' . ($values['local_area_name'] ? $values['local_area_name'] . '/' : '') : '') ?><?= $values['bedrooms'] . "-Bed-" . $values['bathrooms'] . "-Bath-" . $values['ptyle_url'] ?>/<?= $values['propertycode'] ?>?datefrom=<?= $this->Datefrom ?>&dateto=<?= $this->Datefrom ? date('d-m-Y', strtotime($this->dateto)) : $this->Dateto ?>"><img src="<?= IMAGES_URL ?>property/<?= $image ?>"  title="<?php echo $values['image_title']; ?>"></a>
                                <? if (is_special_offer($values['pid'])): ?>
                                    <div class = 'spcl_offer_badge'  >
                                        <img src="<?= IMAGES_URL ?>offer.png" style="box-shadow:none;" />
                                    </div>                    
                                <? endif; ?>
                            </div><!-- image content ends-->

                            <div class = 'inn_content_search'><!-- big div--> 
                                <?php
                                if ($keys == 0)
                                {
                                    ?>
                                    <h3 class = 'tab_box_heading_search seo-header-tag font-15' style="font-size:15px;color:#0f6bb5;font-weight:bold;"><a style="color:#0f6bb5;" href="<?= APPLICATION_URL ?>holiday-rentals/<?= $values['country_name'] ?>/<?= $values['state_name'] ?>/<?= $values['city_name'] . "/" . ($values['sub_area_name'] ? $values['sub_area_name'] . '/' . ($values['local_area_name'] ? $values['local_area_name'] . '/' : '') : '') ?><?= $values['bedrooms'] . "-Bed-" . $values['bathrooms'] . "-Bath-" . $values['ptyle_url'] ?>/<?= $values['propertycode'] ?>?datefrom=<?= $this->Datefrom ?>&dateto=<?= $this->Datefrom ? date('d-m-Y', strtotime($this->dateto)) : $this->Dateto ?>" title="See the full description, availability calendar, rates, photos, map and reviews" class="mws-tooltip-s"><?= $values['property_title'] ?></a></h3>
                                    <?php
                                }
                                else
                                {
                                    ?>
                                    <a class="mws-tooltip-s" title="See the full description, availability calendar, rates, photos, map and reviews" href="<?= APPLICATION_URL ?>holiday-rentals/<?= $values['country_name'] ?>/<?= $values['state_name'] ?>/<?= $values['city_name'] . "/" . ($values['sub_area_name'] ? $values['sub_area_name'] . '/' . ($values['local_area_name'] ? $values['local_area_name'] . '/' : '') : '') ?><?= $values['bedrooms'] . "-Bed-" . $values['bathrooms'] . "-Bath-" . $values['ptyle_url'] ?>/<?= $values['propertycode'] ?>?datefrom=<?= $this->Datefrom ?>&dateto=<?= $this->Datefrom ? date('d-m-Y', strtotime($this->dateto)) : $this->Dateto ?>"><span class = 'tab_box_heading_search font-15'><?= $values['property_title'] ?></span></a>
                                    <?php
                                }
                                ?>
                                <span class = 'tab_box_ppty_type'><?= $values['ptyle_url'] ?></span>
                                <?php
                                if ($keys == 0)
                                {
                                    ?>
                                    <span class="tab_box_ppty_number">Property No: <h3 class="green seo-header-tag" style="width:80px;float:none;color:#4eb84e;font-size:13px;"><?= $values['propertycode'] ?></h3></span>
                                    <?php
                                }
                                else
                                {
                                    ?>
                                    <span class="tab_box_ppty_number">Property No: <span class="green"><?= $values['propertycode'] ?></span></span>
                                    <?php
                                }
                                ?>
                                <span class="bedroom_numbers" >  <?= rtrim($values['bedrooms'], ".0"); ?> Bed  <?= rtrim($values['bathrooms'], ".0"); ?> Bath - Sleeps <?= $values['maximum_occupancy'] ?></span>
                                <?php
                                if ($values['is_insured'] == '1')
                                {
                                    echo '<br/><p style="font-size: 9px;white-space:nowrap;float:left;width:64%;padding:5px 5px 5px 10px;">Property Protection Home Insurance Included</p>';
                                }
                                ?>

                                <div class = "rytImgSearch">
                                    <span ><? rating_view($values['star_rating']); ?></span>
            <!--<span class = "review">Reviews (<span class = 'green'><?= review_count($values['pid']) ?></span>) </span>-->
                                    <?php
                                    $avg_customer_rating = avg_customer_rating($values['pid']);
                                    if ($avg_customer_rating != '0/10')
                                    {
                                        ?>
                                        <span class = "review">Customer Rating: <span class = 'yellow'><?= $avg_customer_rating; ?></span> </span><br/><br/>
                                        <?php
                                    }
                                    ?>
            <!--<span class = 'briefDesc'>	
            <?= $values['brief_desc'] ?>
            </span>-->
            <!--<span class="online-booking-status">Online Booking Status:</span>-->

                                </div>
                            </div>   
                            <div class = 'detailBtn' > <!-- div for buttons -->
                                <div class="price_n_rating" align="right">
                                    <?
                                    if ($values['prate'] != "")
                                    {
                                        ?>
                                        <div class="search_price"><strong><?= $this->Datefrom ? "Price:" : "From " ?>&pound;<?
                            $rate = explode('.', $values['total_amount']);
                            echo $rate[0] ? $rate[0] : (int) ($values['prate'] * (($this->Dateto && $this->Datefrom) ? $this->Dateto : $values['nights']))
                                        ?> for <?= ($this->Dateto && $this->Datefrom) ? ($this->Dateto) : $values['nights'] ?> nights</strong></div>
                                        <?
                                    }
                                    else
                                    {
                                        ?>
                                        <div class="search_price"><? echo "Unknown" ?></div>
                        <!--                <div>For <?= ceil($values['nights']) ?> nights</div>-->
                <?
            }
            ?>
            <!--<span class = "crating">Customer Rating: <span class = 'yellow'><?= avg_customer_rating($values['pid']) ?></span> </span>-->	
                                </div>
                                <a class="btn floatR mws-tooltip-e" rel="nofollow" href="<?= APPLICATION_URL ?>booking/index/ppty/<?= $values['pid'] ?>/datefrom/<?= $this->Datefrom ?>/dateto/<?= $this->Dateto ?>/step/1" id = "Link<?= $i ?>" title="<?= cal_availability($values['pid'], 1) ?>"><span class="floatL">Book Now</span> <?= cal_availability($values['pid'], 0) == '2' ? '<img class = "floatL" src="' . IMAGES_URL . 'check_available.png" width="25" height="22">' : '<img class = "floatL" src="' . IMAGES_URL . 'question-balloon_yellow.png" width="25" height="22">' ?></span></a>


                                <!--                                <br />
                                                                <br />-->
                                <!--                                <div class="edit_btns">
                                                                    <div class="btns" > first div 
                                                                        <a href='<?= APPLICATION_URL ?>property/preview/<?= $values['country_name'] ?>/<?= $values['state_name'] ?>/<?= $values['city_name'] . "/" . ($values['sub_area_name'] ? $values['sub_area_name'] . '/' . ($values['local_area_name'] ? $values['local_area_name'] . '/' : '') : '') ?>property-code-<?= $values['propertycode'] ?>/?datefrom=<?= $this->Datefrom ?>&dateto=<?= $this->Datefrom ? date('d-m-Y', strtotime($this->dateto)) : $this->Dateto ?>'>View Details</a>
                                                                    </div>
                                                                </div>-->
																<?php //echo "<pre />"; print_r($values); ?>
                                <div class="new-green-gradient-btn">
                                    <a href='<?= APPLICATION_URL ?>holiday-rentals/<?= $values['country_name'] ?>/<?= $values['state_name'] ?>/<?= $values['city_name'] . "/" . ($values['sub_area_name'] ? $values['sub_area_name'] . '/' . ($values['local_area_name'] ? $values['local_area_name'] . '/' : '') : '') ?><?= $values['bedrooms'] . "-Bed-" . $values['bathrooms'] . "-Bath-" . $values['ptyle_url'] ?>/<?= $values['propertycode'] ?>?datefrom=<?= $this->Datefrom ?>&dateto=<?= $this->Datefrom ? date('d-m-Y', strtotime($this->dateto)) : $this->Dateto ?>' title="View Details of Rental - <?php echo $values['propertycode']; ?>" class="mws-tooltip-s">View Details</a>
                                </div>
								<?php $ppt_ids = $values['pid']; ?>
							<div class='new-gray-gradient-btn' ><span class="mws-tooltip-s" id="offercontrol<?php echo $ppt_ids;?>" onclick="showoffer('<?php echo $ppt_ids; ?>')">special offer</span></div>	
                            </div>
							<!-- div for button ends -->           
                            <!--<span id = "book_online_text" >Book Online or Call: 0845 121 0160</span>-->      
                        </div><!-- box div (main) ends-->
						<div class="special-offer-div" id='offer-div<?php echo $ppt_ids;?>' style="display:none;">
					
						</div>
                        <?
                        $i++;
                    }

                endif;

                if ($this->gridType == '2'):

                    $i = 0;
                    ?>	
                    <div class="photoGrid">

                        <?
                        foreach ($this->propertyData as $values)
                        {

                            if ($values['image_name'])
                                $image = $values['image_name'];
                            else
                                $image = "generic.jpg";
                            ?>	
                            <div class="hotel-result-grid ">
                                <!--<span style="color:#0F6BB5;width:100%;margin-bottom:20px;">Property No: <span class="green"><?= $values['propertycode'] ?></span></span>-->
                                <span class="tab_box_ppty_number">Property No: <span class="green"><?= $values['propertycode'] ?></span></span>
                                <div class="hotel-image-holder">
                                    <? if (is_special_offer($values['pid'])): ?>
                                        <div class = 'spcl_offer_badge'  >
                                            <img src="<?= IMAGES_URL ?>offer.png" style="box-shadow:none;" />
                                        </div>                    
            <? endif; ?>
                                    <img title="View hotel details" alt="Hotel photo" src="<?= IMAGES_URL ?>property/<?= $image ?>" class="hotel-image-gallery-view trp-round-3 image-shadow viewDetailsLink"></div>
                                <h3 class="hotel-name ellipses-overflow">
                                    <a title="View hotel details" id="hotelName-126513" class="viewDetailsLink"><?= $values['property_title'] ?></a>
                                </h3>
                                <h5 class="hotel-location ellipses-overflow"><?= $values['bedrooms'] ?> bedrooms  <?= ceil($values['bathrooms']) ?> bathrooms - Sleeps up to <?= $values['maximum_occupancy'] ?></h5>
                                <div class="hotel-star-holder">
                                    <span><? rating_view($values['star_rating']); ?></span>
                                </div>

                                <div class="roomsFromHolder">
                                    <?
                                    if ($values['prate'] != "")
                                    {
                                        ?>
                                        <div class="search_price"><?= $this->Datefrom ? "Price:" : "From " ?>&pound; <?
                            $rate = explode('.', $values['total_amount']);
                            echo $rate[0] ? $rate[0] : $values['prate'] * $values['nights']
                                        ?> for <?= ($rate[0] && $this->Dateto) ? ($this->Dateto) : $values['nights'] ?> nights</div>

                                        <?
                                    }
                                    else
                                    {
                                        ?>
                                        <div class="search_price"> <? echo "Unknown" ?></div>
                        <!--                <div>For <?= ceil($values['nights']) ?> nights</div>-->
                <?
            }
            ?>


                                </div>



                                <?
                                /* 	if(isLogged()):
                                  ?>

                                  <div class="favLink" style="float:left;">
                                  <?
                                  $text = "Add as Favourite";
                                  foreach($this->favArr as $val)
                                  {
                                  if($val == $values['pid'])
                                  $text = "Remove as Favourite";

                                  }
                                  ?>
                                  <a href="javascript:void(0);" id = "Link<?=$i?>" onclick="add_as_favourite(<?=$values['pid']?>,this.id)"><img src="<?=IMAGES_URL?>package_favourite.png" height="25px" width="25px"/><span><?=$text?></span></a>
                                  </div>
                                  <?
                                  endif; */
                                ?>
                                <div class="new-green-gradient-btn">
                                    <!--<div class="btns" > first div -->
                                    <!--<a href='<?= APPLICATION_URL ?>property/preview/<?= $values['country_name'] ?>/<?= $values['state_name'] ?>/<?= $values['city_name'] . "/" . ($values['sub_area_name'] ? $values['sub_area_name'] . '/' . ($values['local_area_name'] ? $values['local_area_name'] . '/' : '') : '') ?>property-code-<?= $values['propertycode'] ?>/?datefrom=<?= $this->Datefrom ?>&dateto=<?= $this->Datefrom ? date('d-m-Y', strtotime($this->dateto)) : $this->Dateto ?>'>View Detail</a>-->
                                    <a href='<?= APPLICATION_URL ?>holiday-rentals/<?= $values['country_name'] ?>/<?= $values['state_name'] ?>/<?= $values['city_name'] . "/" . ($values['sub_area_name'] ? $values['sub_area_name'] . '/' . ($values['local_area_name'] ? $values['local_area_name'] . '/' : '') : '') ?><?= $values['bedrooms'] . " Bed " . round($values['bathrooms']) . " Bath " . $values['ptyle_url'] ?>/<?= $values['propertycode'] ?>?datefrom=<?= $this->Datefrom ?>&dateto=<?= $this->Datefrom ? date('d-m-Y', strtotime($this->dateto)) : $this->Dateto ?>'>View Details</a>
                                    <!--</div>-->
                                </div>

                            </div>


                            <?
                            $i++;
                        }
                        ?>	
                    </div>

                    <?
                endif;


                if ($this->gridType == '3'):
//
//                    $gMap = "";
//                    foreach ($this->propertyData as $values)
//                    {
//                        if ($values['cletitude'])
//                        {
//                            $gMap .= $values['cletitude'] . "," . $values['clongitude'] . "," . $values['pid'] . "|||";
//                        }
//                    }
//                    $gMap = substr($gMap, 0, strlen($gMap) - 3);
//                    
                    ?>	
                    <?
                    foreach ($this->propertyData as $values)
                    {
                        if ($values['image_name'])
                            $image = $values['image_name'];
                        else
                            $image = "generic.jpg";
                        ?>	
                        <div class="ppty_list_search"><!-- box div (main) starts-->
                            <div class = 'left_panel_heading_ppty_search'> <!-- top div -->
                                <div class="location_bread_crum">
            <?= breadcrumb_trail($values['country_name'], $values['state_name'], $values['city_name'], $values['sub_area_name'], $values['local_area_name']) ?>
            <? /* if($values['address']) echo $values['address']; else echo "[No Location described]"; */ ?>  
                                </div>
                            </div> <!-- top div ends -->           

                            <div class = 'img_wrapper_search'><!-- image content-->
                                <img src="<?= IMAGES_URL ?>property/<?= $image ?>"  >
                                <? if (is_special_offer($values['pid'])): ?>
                                    <div class = 'spcl_offer_badge'  >
                                        <img src="<?= IMAGES_URL ?>offer.png" style="box-shadow:none;" />
                                    </div>                    
            <? endif; ?>
                            </div><!-- image content ends-->

                            <div class = 'inn_content_search'><!-- big div--> 
                                <span class = 'tab_box_heading_search'><?= $values['property_title'] ?></span>

                                <span class = 'tab_box_ppty_type'><?= $values['ptyle_url'] ?></span>                
                                <!--<span style="float:right;color:#0F6BB5;">Property No: <span class="green"><?= $values['propertycode'] ?></span></span>-->
                                <span class="tab_box_ppty_number">Property No: <span class="green"><?= $values['propertycode'] ?></span></span>
                                <span class="bedroom_numbers" >  <?= $values['bedrooms'] ?> bedrooms  <?= ceil($values['bathrooms']) ?> bathrooms - Sleeps up to <?= $values['maximum_occupancy'] ?></span>

                                <div class = "rytImgSearch">
                                    <span><? rating_view($values['star_rating']); ?></span>
                                    <!--<span class = "review">Reviews (<span class = 'green'><?= review_count($values['pid']) ?></span>) </span>-->
                                    <span class = "review">Customer Rating: <span class = 'yellow'><?= avg_customer_rating($values['pid']) ?></span> </span>
                                                                            <!--<span class = 'briefDesc'>	
            <?= $values['brief_desc'] ?>
                                         </span>-->
                                    <!--<span>Online Booking Status:</span>-->

                                </div>
                            </div>   



                            <div class = 'detailBtn' > <!-- div for buttons -->

                                <div class="price_n_rating" align="right">


                                    <?
                                    if ($values['prate'] != "")
                                    {
                                        ?>
                                        <div class="search_price"><?= $this->Datefrom ? "Price:" : "From " ?>&pound;<?
                            $rate = explode('.', $values['total_amount']);
                            echo $rate[0] ? $rate[0] : (int) ($values['prate'] * (($this->Dateto && $this->Datefrom) ? $this->Dateto : $values['nights']))
                                        ?> for <?= ($this->Dateto && $this->Datefrom) ? ($this->Dateto) : $values['nights'] ?> nights</div>

                                        <?
                                    }
                                    else
                                    {
                                        ?>
                                        <div class="search_price"><? echo "Unknown" ?></div>
                        <!--                <div>For <?= ceil($values['nights']) ?> nights</div>-->
                <?
            }
            ?>
            <!--<span class = "crating">Customer Rating: <span class = 'yellow'><?= avg_customer_rating($values['pid']) ?></span> </span>-->	
                                </div>
                                <?
                                /* 	if(isLogged()):
                                  ?>


                                  <div class="favLink">
                                  <?
                                  $text = "Add as Favourite";

                                  foreach($this->favArr as $val)
                                  {
                                  if($val == $values['pid'])
                                  {
                                  $text = "Remove as Favourite";

                                  }
                                  }
                                  ?>
                                  <a href="javascript:void(0);" id = "Link<?=$i?>" onclick="add_as_favourite(<?=$values['pid']?>,this.id)"><img src="<?=IMAGES_URL?>package_favourite.png" height="25px" width="25px"/><span><?=$text?></span></a>

                                  </div>

                                  <?
                                  endif; */
                                ?>     


                                <a class="btn floatR mws-tooltip-e" href="<?= APPLICATION_URL ?>booking/index/ppty/<?= $values['pid'] ?>/datefrom/<?= $this->Datefrom ?>/dateto/<?= $this->Dateto ?>/step/1" id = "Link<?= $i ?>" title="<?= cal_availability($values['pid'], 1) ?>"><span class="floatL">Book Now</span> <?= cal_availability($values['pid'], 0) == '2' ? '<img class = "floatL" src="' . IMAGES_URL . 'check_available.png" width="25" height="22">' : '<img class = "floatL" src="' . IMAGES_URL . 'question-balloon_yellow.png" width="25" height="22">' ?></span></a>


                                <!--                                <br />
                                                                <br />-->
                                <div class="new-green-gradient-btn">
                                    <!--<div class="btns" > first div -->
                                    <!--<a href='<?= APPLICATION_URL ?>property/preview/<?= $values['country_name'] ?>/<?= $values['state_name'] ?>/<?= $values['city_name'] . "/" . ($values['sub_area_name'] ? $values['sub_area_name'] . '/' . ($values['local_area_name'] ? $values['local_area_name'] . '/' : '') : '') ?>property-code-<?= $values['propertycode'] ?>/?datefrom=<?= $this->Datefrom ?>&dateto=<?= $this->Datefrom ? date('d-m-Y', strtotime($this->dateto)) : $this->Dateto ?>'>View Details</a>-->
                                    <a href='<?= APPLICATION_URL ?>holiday-rentals/<?= $values['country_name'] ?>/<?= $values['state_name'] ?>/<?= $values['city_name'] . "/" . ($values['sub_area_name'] ? $values['sub_area_name'] . '/' . ($values['local_area_name'] ? $values['local_area_name'] . '/' : '') : '') ?><?= $values['bedrooms'] . " Bed " . round($values['bathrooms']) . " Bath " . $values['ptyle_url'] ?>/<?= $values['propertycode'] ?>?datefrom=<?= $this->Datefrom ?>&dateto=<?= $this->Datefrom ? date('d-m-Y', strtotime($this->dateto)) : $this->Dateto ?>'>View Details</a>
                                    <!--</div>-->
                                </div>


                            </div> <!-- div for button ends -->           
                            <!--<span id = "book_online_text" >Book Online or Call: 0845 121 0160</span>-->      
                        </div><!-- box div (main) ends-->

                        <?
                        $i++;
                    }
                endif;

                if (count($this->propertyData) == 0)
                {
                    echo " <div class='floatL no_result'>";
                    echo "<span class='red'>Sorry!</span>  We have not located any properties that match your search criteria. Please try again by removing one or more of your Advance Search selections.
			  Alternatively, you may wish to <a href='javascript:reset_filter();' class='link' style='font-size:21px;text-decoration:underline;'>start a new search</a> (this will clear all your current search filters).";
                    echo "</div>";
                }


                if ($this->gridType != '3'):
                    ?>
                    <div class="pagging_search" >
                        <?
                        // echo myPagingSearch($this->now, $this->total, $this->start, $this->limit) 

                        echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml', array('queryString' => $this->queryString));
                        ?>
                    </div>
        <?
    endif;
?>    
        </div>  
    </div>	
</div> 
<script>
    function showoffer(pid)
	{
	 if($("#offercontrol"+pid).html() == "close offer"){
	 $("#offer-div"+pid).html('');
	 $("#offer-div"+pid).hide();
	 $("#offercontrol"+pid).html("special offer");
	 }else{
	    $.ajax({url: "<?= APPLICATION_URL . "search/getspecialoffer" ?>",
            type: "POST",
            data: ({pid: pid}),
            success: function(data)
            {
			  $("#offer-div"+pid).html(data);
			  $("#offer-div"+pid).show();
			  $("#offercontrol"+pid).html("close offer");
            }
		});
	}
	}
    function getCountryState(countryId)
    {
        countryId = $.trim(countryId);
        if (countryId == "")
        {
            $("#state_id_div").hide();
            $("#city_id_div").hide();
            $("#sub_area_id_div").hide();
            $("#local_area_id_div").hide();
        }
        else
        {
            $("#state_id_div").show();
        }
        $.ajax({url: "<?= APPLICATION_URL . "index/getstatebycountrycount" ?>",
            type: "POST",
            data: ({countryId: countryId}),
            success: function(data)
            {


                EmptyListbox('state_id');
                EmptyListbox('city_id');
                EmptyListbox('sub_area_id');
                EmptyListbox('local_area_id');

                AddOptiontoListBox('state_id', '', '- - All States - -');
                AddOptiontoListBox('city_id', '', '- - All Cities - -');
                AddOptiontoListBox('sub_area_id', '', '- - All Sub Areas - -');
                AddOptiontoListBox('local_area_id', '', '- - All Local Areas - -');

                data = $.trim(data);
                if (data != '')
                {



                    var ArrData = data.split("***");

                    if (ArrData.length > 0)
                    {
                        for (var i = 0; i < ArrData.length; i++)
                        {
                            var mySplit = ArrData[i].split("|||");
                            var OptionValue = mySplit[0];
                            var OptionText = mySplit[1] + ' (' + mySplit[2] + ')';
                            AddOptiontoListBox('state_id', OptionValue, OptionText);
                        }
                    }

                }
                else
                {
                    $("#city_id_div").hide();
                    $("#sub_area_id_div").hide();
                    $("#local_area_id_div").hide();
                }

            }

        });
    }
    function getStateCity(stateId)
    {
        if (stateId == "")
        {
            $("#city_id_div").hide();
            $("#sub_area_id_div").hide();
            $("#local_area_id_div").hide();
        }
        else
        {
            $("#city_id_div").show();
        }

        $.ajax({url: "<?= APPLICATION_URL . "index/getcitiesbystatecount" ?>",
            type: "POST",
            data: ({stateId: stateId}),
            success: function(data)
            {



                EmptyListbox('city_id');
                EmptyListbox('sub_area_id');
                EmptyListbox('local_area_id');


                AddOptiontoListBox('city_id', '', '- - All Cities - -');
                AddOptiontoListBox('sub_area_id', '', '- - All Sub Areas - -');
                AddOptiontoListBox('local_area_id', '', '- - All Local Areas - -');

                data = $.trim(data);
                if (data != "")
                {
                    var ArrData = data.split("***");
                    if (ArrData.length > 0)
                    {
                        for (var i = 0; i < ArrData.length; i++)
                        {
                            var mySplit = ArrData[i].split("|||");
                            var OptionValue = mySplit[0];
                            var OptionText = mySplit[1] + ' (' + mySplit[2] + ')';
                            AddOptiontoListBox('city_id', OptionValue, OptionText);
                        }

                    }

                }
                else
                {
                    $("#sub_area_id_div").hide();
                    $("#local_area_id_div").hide();
                }
            }
        });

    }

    function getCitySubarea(cityId)
    {
        if (cityId == "")
        {
            $("#sub_area_id_div").hide();
            $("#local_area_id_div").hide();
        }
        else
        {
            $("#sub_area_id_div").show();
        }

        $.ajax({url: "<?= APPLICATION_URL . "index/getsubareabycitycount" ?>",
            type: "POST",
            data: ({cityId: cityId}),
            success: function(data)
            {

                EmptyListbox('sub_area_id');
                EmptyListbox('local_area_id');
                AddOptiontoListBox('sub_area_id', '', '- - All Sub Areas - -');
                AddOptiontoListBox('local_area_id', '', '- - All Local Areas - -');

                data = $.trim(data);
                if (data != "")
                {
                    var ArrData = data.split("***");
                    if (ArrData.length > 0)
                    {
                        for (var i = 0; i < ArrData.length; i++)
                        {
                            var mySplit = ArrData[i].split("|||");
                            var OptionValue = mySplit[0];
                            var OptionText = mySplit[1] + ' (' + mySplit[2] + ')';
                            AddOptiontoListBox('sub_area_id', OptionValue, OptionText);
                        }

                    }

                }
                else
                {
                    $("#local_area_id_div").hide();
                }

            }
        });

    }

    function getSubareaLocalarea(subId)
    {
        if (subId == "")
        {
            $("#local_area_id_div").hide();
        }
        else
        {
            $("#local_area_id_div").show();
        }

        $.ajax({url: "<?= APPLICATION_URL . "index/getlocalareabysubcount" ?>",
            type: "POST",
            data: ({subId: subId}),
            success: function(data)
            {

                EmptyListbox('local_area_id');
                AddOptiontoListBox('local_area_id', '', '- - All Local Area - -');
                data = $.trim(data);
                if (data != "")
                {
                    var ArrData = data.split("***");
                    if (ArrData.length > 0)
                    {
                        for (var i = 0; i < ArrData.length; i++)
                        {
                            var mySplit = ArrData[i].split("|||");
                            var OptionValue = mySplit[0];
                            var OptionText = mySplit[1] + ' (' + mySplit[2] + ')';
                            AddOptiontoListBox('local_area_id', OptionValue, OptionText);
                        }

                    }
                }

            }
        });

    }
<?
    if (isset($this->country_id) && $this->country_id != "")
    {
        ?>
                    $("#state_id_div").show();
        <?
    }
    if (isset($this->state_id) && $this->state_id != "")
    {
        ?>
                    $("#city_id_div").show();

        <?
    }
    if (isset($this->city_id) && $this->city_id != "")
    {
        ?>
                    $("#sub_area_id_div").show();
        <?
    }
    if (isset($this->sub_area_id) && $this->sub_area_id != "")
    {
        ?>
                    $("#local_area_id_div").show();
    <? }
?>
</script>
